package com.zhima.feignclient;

import com.zhima.dto.FeignDownloadResultDTO;
import com.zhima.dto.FeignUploadFileDTO;
import com.zhima.dto.FeignUploadResultDTO;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.web.bind.annotation.*;

@FeignClient("oj-file-service")
@RequestMapping("/oj-file/file/feign")
public interface FileFeignClient {
    /**
     * 上传文件到指定桶中
     *
     * @param feignUploadFileDTO
     * @param bucket
     * @return
     */
    @PostMapping("/{bucket}/{uploaderId}")
    FeignUploadResultDTO upload(@PathVariable("uploaderId") Long uploaderId, @RequestBody FeignUploadFileDTO feignUploadFileDTO, @PathVariable("bucket") String bucket);

    /**
     * 根据{fileId}下载文件
     *
     * @param fileId
     * @return
     */
    @GetMapping("/f/{fileId}")
    FeignDownloadResultDTO downloadByFileId(@PathVariable("fileId") Long fileId);

    /**
     * 根据{objectId}下载文件
     *
     * @param objectId
     * @return
     */
    @GetMapping("/o/{objectId}")
    FeignDownloadResultDTO downloadByObjectId(@PathVariable("objectId") String objectId);

    @DeleteMapping("/{fileId}")
    void deleteFileByFileId(@PathVariable("fileId") Long fileId);
}
